package com.qf.smsplatform.webmaster.service.api;

import com.qf.smsplatform.webmaster.pojo.ClientChannelStrategy;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
import java.util.Set;

@FeignClient(value = "SMS-PLATFORM-CACHE", fallback = CacheServiceFallback.class)
public interface CacheService {

    @RequestMapping(value = "/cache/get/{key}", method = RequestMethod.GET)
    String get(@PathVariable("key") String key);
    
    @RequestMapping(value = "/cache/get-object/{key}", method = RequestMethod.GET)
    Object getObject(@PathVariable("key") String key);

    @RequestMapping(value = "/cache/delete", method = RequestMethod.POST)
    boolean del(@RequestParam("keys") String... keys);

    @RequestMapping(value = "/cache/hmset/{key}", method = RequestMethod.POST)
    boolean hMSet(@PathVariable("key") String key, @RequestBody Map map);

    @RequestMapping(value = "/cache/hmget/{key}", method = RequestMethod.GET)
    public Map hMGet(@PathVariable("key") String key);

    @RequestMapping(value = "/cache/save2cache", method = RequestMethod.POST)
    void set(@RequestParam("key") String key, @RequestParam("value") String value, @RequestParam("expireSecond") Long expireSecond);

    @RequestMapping(value = "/cache/save2cache-persist", method = RequestMethod.POST)
    void saveCache(@RequestParam("key") String key, @RequestParam("value") String value);

    @RequestMapping(value = "/cache/incr", method = RequestMethod.GET)
    public Long incr(@RequestParam("key") String key, @RequestParam("delta") long delta);

    //保存key-set到redis中，传入的value是String数组可变长度类型
    @RequestMapping(value = "/cache/sadd/{key}",method = RequestMethod.POST)
    public boolean sadd(@PathVariable(value = "key")String key,@RequestParam String... set);

    //保存key-set到redis中，传入的value是set集合
    @RequestMapping(value = "/cache/saddSet/{key}", method = RequestMethod.POST)
    boolean saddObject(@PathVariable("key") String key, @RequestBody Object[] set);

    //保存数据到redis的zset结构中，zadd key score  member
    @RequestMapping(value = "/cache/zadd", method = RequestMethod.POST)
    public boolean zadd(@RequestParam("key") String key, @RequestParam("value") Long value, @RequestParam("member") Long member);

    //通过key和指定field将对应的value进行增加
    @RequestMapping(value = "/cache/hincr/{key}/{field}/{delta}", method = RequestMethod.POST)
    public Long hincr(@PathVariable("key") String key,@PathVariable("field") String field, @PathVariable("delta") long delta);
}
